<template>
	<Layout class="p-5 bg-white">
		<Form :label-width="80">
			<FormItem class="w-50" label="课程编号">
				<label>{{course.courseId}}</label>
			</FormItem>
			<FormItem class="w-50" label="课程名称">
				<label>{{course.name}}</label>
			</FormItem>
			<FormItem class="w-50" label="课程时长">
				<label>{{course.longs}}</label>
			</FormItem>
			<FormItem class="w-50" label="课程价格">
				<label>{{course.price}}</label>	
			</FormItem>
			<FormItem class="w-50" label="课程描述">
			<label>{{course.des}}</label>	
		 </FormItem>
			<!-- 这个地方数据类型有点问题 因为是假数据 我懒得纠结 -->	
			<FormItem class="w-50" label="课程人数">
		<label>{{course.count}}</label>	
		<!-- 		<Input v-model="course.count" placeholder="请输入课程人数"></Input>
			 --></FormItem>
			<FormItem class="w-50" label="课程状态">
					<label>{{course.activeFlg}}</label>	
<!-- 				<Radio-group v-model="course.activeFlg">
					<Radio label="true">上架</Radio>
					<Radio label="false">下架</Radio>
				</Radio-group> -->
			</FormItem>
			<FormItem class="" label="课程类型">
					<label>{{course.typeId}}</label>	
			<!-- 	<Select v-model="course.typeId">
					<Option value=51>sac</Option>
				</Select> -->
			</FormItem>
			
	 
		</Form>
	</Layout>
</template>
<script>
    export default {
        data() {
            return {
			 
                course: {
                    courseId: "",
                    name: "",
					longs: "",
					price: "",
					des: "",
					typeId: "",
					activeFlg: "",
					delFlg: "",
					count: ""
                },
				 
                roles: [],
                allRoles: [],
                // updateFlg: false,
                // oldUser: {},
                // oldRoles: [],

            }
        },
        methods: {
            cancel: function () {
                this.$tabs.close();
            },
            submit: function () {
                let self = this;
				// self.user.openId = 0;
				delete self.course.courseId;
				delete self.course.name;
				delete self.course.longs;
				delete self.course.price;
				delete self.course.des;
				delete self.course.typeId;
				delete self.course.activeFlg;
				delete self.course.delFlg;
				delete self.course.count;
		 	
				console.log(self.course);
                this.http.put({
                    url: "/course/info",
                    param: self.course,
                }).then(() => {
                    self.message.info("修改成功");
                });
            },
            init: function () {
                this.search();
            },
            searchUser: function () {
                let self = this;

                this.http.get({
                    url: "/course/info",
                    param: {
                        courseId: self.$data.course.courseId
                    }
                }).then(data => {
                    console.log(data);
					self.course = data.course;
					for (let jndex in self.allRoles) {
						let role = self.allRoles[jndex];
						role.has = false;
						for (let index in data.roles) {
							let roleItem = data.roles[index];
							if (roleItem.roleId == role.roleId) {
								role.has = true;
								this.roles.push(role);
							}
						}
					}
					
                });
            },

            search: function () {
                let self = this;
                this.http.get({
                    url: "/course/info",
					param: {
					    courseId: this.$data.course.courseId
					}
                }).then(data => {
                    self.$data.course = data;
                }).then(() => {
                    self.searchUser();
                });
            }

        },

        created: function () {
        },
        mounted: function () {
			this.$data.course.courseId = this.$route.params.courseId;
            this.init();
        }
    }
</script>

<style>
</style>
